Unit Uconfiguracao;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, Sysutils, Fileutil, Lresources, Forms, Controls, Graphics,
  Dialogs, StdCtrls, ExtCtrls, DbCtrls, ComCtrls, db;

Type

  { TFConfiguracao }

  TFConfiguracao = Class(Tform)
    ButtonPastaOrigem: TButton;
    ButtonSair: TButton;
    ButtonPastaDestino: TButton;
    Dbcheckbox1: Tdbcheckbox;
    Dbcheckbox10: Tdbcheckbox;
    Dbcheckbox11: Tdbcheckbox;
    Dbcheckbox12: Tdbcheckbox;
    Dbcheckbox2: Tdbcheckbox;
    Dbcheckbox3: Tdbcheckbox;
    Dbcheckbox4: Tdbcheckbox;
    Dbcheckbox5: Tdbcheckbox;
    Dbcheckbox6: Tdbcheckbox;
    Dbcheckbox7: Tdbcheckbox;
    Dbcheckbox8: Tdbcheckbox;
    Dbcheckbox9: Tdbcheckbox;
    DBEditLimite: TDBEdit;
    DBEditNome: TDBEdit;
    DBEditOrigem: TDBEdit;
    DBEditDestino: TDBEdit;
    Dbnavigator1: Tdbnavigator;
    Label1: Tlabel;
    Label2: Tlabel;
    LabelOrigem: TLabel;
    LabelDestino: TLabel;
    LabelNome: TLabel;
    SelectDirectoryDialog: TSelectDirectoryDialog;
    UpDown: TUpDown;
    Procedure Buttonexcluirclick(Sender: Tobject);
    Procedure Buttonpastadestinoclick(Sender: Tobject);
    Procedure Buttonpastaorigemclick(Sender: Tobject);
    Procedure Buttonsairclick(Sender: Tobject);
    Procedure Dbabeforepost(Dataset: Tdataset);
    Procedure Editnomeexit(Sender: Tobject);
    Procedure Formclose(Sender: Tobject);
    Procedure Formclosequery(Sender: Tobject; Var Canclose: Boolean);
    Procedure Formcreate(Sender: Tobject);
  Private
     CaptionOriginal : String;
    { Private Declarations }
  Public
    { Public Declarations }
  End; 

Var
  FConfiguracao: TFConfiguracao;

Implementation
uses
    UBackup;
{ TFConfiguracao }

Procedure Tfconfiguracao.Editnomeexit(Sender: Tobject);
Begin
  //FConfiguracao.Caption:= CaptionOriginal + ' - ' + EditNome.Text;
End;

Procedure Tfconfiguracao.Formclose(Sender: Tobject);
Begin
  FormBackup.DBA.Cancel;
  FormBackup.Visible := true;
End;

Procedure Tfconfiguracao.Formclosequery(Sender: Tobject; Var Canclose: Boolean);
Begin
{
  CanClose:=Not (FormBackup.DBA.State in );
  if Not CanClose then
    case MessageDlg('Salvar dados antes de sair?',mtWarning,[mbYes,mbNo,mbCancel],0) of
      mrYes : begin
              DBA.Post;
              CanClose:=True;
              end;
      mrNo  : CanClose:=True;
    end;   }
End;



Procedure Tfconfiguracao.Buttonsairclick(Sender: Tobject);
Begin
  Close;
End;

Procedure Tfconfiguracao.Dbabeforepost(Dataset: Tdataset);
Begin
  if not Length(DBEditNome.Text) > 0 then begin
     ShowMessage('Deve haver um nome!');
     DBEditNome.SetFocus;
  end else if not Length(DBEditDestino.Text) > 0 then begin
     ShowMessage('Deve haver um Destino!');
     DBEditDestino.SetFocus;
  end else if not Length(DBEditOrigem.Text) > 0 then begin
     ShowMessage('Deve haver uma Origem!');
     DBEditOrigem.SetFocus;
  end;
End;

Procedure Tfconfiguracao.Buttonexcluirclick(Sender: Tobject);
Begin
  if MessageDlg('Deseja realmente excluir?', mtConfirmation,[mbYes,mbNo],0) = mrYes then FormBackup.DBA.Delete;
End;

Procedure Tfconfiguracao.Buttonpastadestinoclick(Sender: Tobject);
Begin
   SelectDirectoryDialog.Execute;
   DBEditDestino.Text := SelectDirectoryDialog.FileName;
End;

Procedure Tfconfiguracao.Buttonpastaorigemclick(Sender: Tobject);
Begin
   SelectDirectoryDialog.Execute;
   DBEditOrigem.Text := SelectDirectoryDialog.FileName;
End;

Procedure Tfconfiguracao.Formcreate(Sender: Tobject);
Begin
  CaptionOriginal := 'Configurações do Backup';
End;

Initialization
  {$I Uconfiguracao.lrs}

End.

